<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ES6新特性</title>
</head>
<body>
    <fieldset>
        <legend>01.es6新特性</legend>
        <p>ES6(ES2015)——IE10+、Chrome、FireFox、移动端、NodeJS</p>
        <p>1,变量</p>
        <p>2,函数</p>
        <p>3,数组</p>
        <p>4,字符串</p>
        <p>5,面向对象</p>
        <p>6,Promise</p>
        <p>7,generator</p>
        <p>8,模块化</p>
    </fieldset>
    <fieldset>
        <legend>02.箭头函数</legend>
        <!-- 
            ()=>{
            }

            1.如果只有一个参数，()可以省
            2.如果只有一个return，{}可以省
        -->
        <script>
            //数组排序案例
            let arrs = [5,2,7,6,9,10,25,12,23,90,67,56,12];
            arrs.sort((n1,n2)=>{return n1-n2});//sort为变异方法
            alert(arrs);
        </script>
    </fieldset>
    <fieldset>
        <legend>03.参数展开</legend>
        <script>
            //参数展开
            let show= (a,b,...args)=>{
                console.log(...args);
            }
            show(1,2,'a','b','c');

            let arr1 = ['1',2,3];
            let arr2 = [6,9,8];
            let arr = [...arr1,...arr2];

            alert(arr);

            //默认参数
            const defaultParam = (a,b=3,c='t')=>{
                console.log(b,c);
            }

            defaultParam(6,'t','n');
        </script>
    </fieldset>

    <fieldset>
        <legend>04.解构赋值</legend>
        <script>
            // 解构赋值：
            // 1.左右两边结构必须一样
            // 2.右边必须是个东西
            // 3.声明和赋值不能分开(必须在一句话里完成)
            let [a,b,c] = [1,6,9];
            console.log(a,b,c);

            let [json,num,arr6] = [{"a":1},8,['a','b','c']];
            console.log(json,num,arr);

            //let [a,b]={a: 12, b: 45}; ×
            //let {a,b} ={12,5}         ×
        </script>
    </fieldset>

    <fieldset>
        <legend>05.数组的新特性</legend>
        <script>
            //filter的特性
            let arr9 = [25,89,12,90,78,67,32,31,79];     
            let result = arr9.filter(item=>item%2);    
            console.log(result);
        </script>
    </fieldset>
</body>
</html>